<?php
    $title = 'บริษัท แบคอัพ คอมมิวนิเคชั่นส์ แอนด์ เซอร์วิสเซส จำกัด';
    include('header.php');
    if(isset($_GET['m_id'])){
	$m_id = $_GET['m_id']+0;
        if($m_id<1 OR $m_id>9){
            $m_id = 1;
        }
    }else{
	$m_id = 1;
    }
    
    $sql = 'SELECT m_id , ms_path , ms_text_'.$_SESSION['lang'].' AS ms_text FROM media_slide WHERE ms_active=1 AND m_id='.$m_id.' ORDER BY ms_position';
    $result = $db->Execute($sql);
    $media_slide[1] = '<ul>';
    $media_slide[2] = '<ul>';
    $media_slide[3] = '<ul>';
    $media_slide[4] = '<ul>';
    $media_slide[5] = '<ul>';
    $media_slide[6] = '<ul>';
    $media_slide[7] = '<ul>';
    $media_slide[8] = '<ul>';
    $media_slide[9] = '<ul>';
    $media_slide_msg = array();
    while (!$result->EOF)
    {
	if($m_id!=3){
	    if(img_exists(APPPATH.'/images/media/'.$result->fields['m_id'],$result->fields['ms_path'])){
		$media_slide[$result->fields['m_id']] .= '<li><img src="'.SITEURL.'/images/media/'.$result->fields['m_id'].'/'.$result->fields['ms_path'].'" title="'.addslashes($result->fields['ms_text']).'" /></li>';
		$media_slide_msg[] = nl2br($result->fields['ms_text']);
	    }
	}else{
	    if($result->fields['ms_path']!=''){
		$url1 = explode('v=',$result->fields['ms_path']);
		$url2 = end($url1);
		$url3 = explode('&',$url2);
		$url4 = $url3[0];
		
		$ms_text = addslashes($result->fields['ms_text']);
		$media_slide[$result->fields['m_id']] .=<<<xxx
		    <li>
			<iframe title="{$ms_text}" width="700" height="450" src="http://www.youtube.com/embed/{$url4}" frameborder="0" allowfullscreen></iframe>
		    </li>
xxx;
		$media_slide_msg[] = nl2br($result->fields['ms_text']);
	    }
	}
        $result->MoveNext();
    }
    $result->Close();
    $media_slide[1] .= '</ul>';
    $media_slide[2] .= '</ul>';
    $media_slide[3] .= '</ul>';
    $media_slide[4] .= '</ul>';
    $media_slide[5] .= '</ul>';
    $media_slide[6] .= '</ul>';
    $media_slide[7] .= '</ul>';
    $media_slide[8] .= '</ul>';
    $media_slide[9] .= '</ul>';
?>
	    <h2 id="media_title"><?php echo _l('Media  Commnunications.'); ?></h2>
            <div id="media_menu">
		
		<ul>
		    <li<?php if($m_id==1){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=1" title="<?php echo _l('Web Development'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Web Development'); ?></a></li>
		    <li<?php if($m_id==2){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=2" title="<?php echo _l('Interactive Presentation'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Interactive Presentation'); ?></a></li>
		    <li<?php if($m_id==3){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=3" title="<?php echo _l('Video Presentation'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Video Presentation'); ?></a></li>
		    <li<?php if($m_id==4){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=4" title="<?php echo _l('E-Magazine Service'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('E-Magazine Service'); ?></a></li>
		    <li<?php if($m_id==5){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=5" title="<?php echo _l('Annual Report'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Annual Report'); ?></a></li>
		    <li<?php if($m_id==6){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=6" title="<?php echo _l('Printing Service'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Printing Service'); ?></a></li>
		    <li<?php if($m_id==7){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=7" title="<?php echo _l('Digital Photography'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Digital Photography'); ?></a></li>
		    <li<?php if($m_id==8){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=8" title="<?php echo _l('Copywriter & Translation Service'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('Copywriter & Translation Service'); ?></a></li>
		    <li<?php if($m_id==9){ echo ' class="current"'; } ?>><a href="media-communication.php?m_id=9" title="<?php echo _l('CD/DVD Production'); ?>"><img src="images/footer_bullet.png" /><?php echo _l('CD/DVD Production'); ?></a></li>
		</ul>
		
	    </div>
	    <div id="media_content">
		
		<?php if($m_id==2): ?>
		<h3 id="media_page_title"><?php echo _l('Interactive Presentation'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-interactive-presentation'); ?>
		  
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[2]; ?>
		</div>
		
		<?php elseif($m_id==3): ?>
		<h3 id="media_page_title"><?php echo _l('Video Presentation'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-video-presentation'); ?>
		    
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[3]; ?>
		</div>
		
		<?php elseif($m_id==4): ?>
		<h3 id="media_page_title"><?php echo _l('E-Magazine Service'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-e-magazine-service'); ?>
		    
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[4]; ?>
		</div>
		
		<?php elseif($m_id==5): ?>
		<h3 id="media_page_title"><?php echo _l('Annual Report'); ?></h3>
		<p class="media_content">
		   
		   <?php echo _l('media-annual-report'); ?>
		   
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[5]; ?>
		</div>
		
		<?php elseif($m_id==6): ?>
		<h3 id="media_page_title"><?php echo _l('Printing Service'); ?></h3>
		<p class="media_content" id="media_print_service">
		    
		    <?php echo _l('media-printing-service'); ?>
		    
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[6]; ?>
		</div>
		
		<?php elseif($m_id==7): ?>
		<h3 id="media_page_title"><?php echo _l('Digital Photography'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-digital-photography'); ?>
		    
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[7]; ?>
		</div>
		
		<?php elseif($m_id==8): ?>
		<h3 id="media_page_title"><?php echo _l('Copywriter & Translation Service'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-copywriter-translation-service'); ?>
		    
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[8]; ?>
		</div>
		
		<?php elseif($m_id==9): ?>
		<h3 id="media_page_title"><?php echo _l('CD/DVD Production'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-cd-dvd-production'); ?>
		    
		</p>
		<div id="media_content_slide">
		    <?php echo $media_slide[9]; ?>
		</div>
		
		<?php else: ?>
		<h3 id="media_page_title"><?php echo _l('Web Development'); ?></h3>
		<p class="media_content">
		    
		    <?php echo _l('media-web-development'); ?>
		
		    <div id="media_content_slide">
			<?php echo $media_slide[1]; ?>
		    </div>
		
		<?php endif; ?>
		
		
		<div id="media_slide_prev"><img src="images/prev.jpg" alt="Previous" /></div>
		<div id="media_slide_msg"><?php echo $media_slide_msg[0]; ?></div>
		<div id="media_slide_next"><img src="images/next.jpg" alt="Next" /></div>
		<div class="clear">&nbsp;</div>
		
	    </div>
	    <div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>
<script type="text/javascript" src="js/jcarousellite_1.0.1.min.js"></script>
<script>
    $(document).ready(function(){
	$('#media_content_slide').jCarouselLite({
	    btnNext: "#media_slide_next img",
	    btnPrev: "#media_slide_prev img",
	    speed: 1500,
	    visible : 1,
	    afterEnd : function(a) {
		if(<?php echo $m_id; ?>!=3){
		    var imgSource = a.find('img').attr('title');
		}else{
		    var imgSource = a.find('iframe').attr('title');
		}
		$('#media_slide_msg').html(imgSource);
	    }
	});
    });
</script>